fileformatsfandomcom-20200215-history
Portable Game Notation
Portable Game Notation (PGN) is a file format for recording chess games. Specification PGN code begins with a set of tag pairs, followed by the moves ("movetext") section. If the result of the game is not "*" (see Tag pairs), it is appended at the end of the movetext section. Tag pairs A tag pair is enclosed in brackets ("",""). The contents are the name of the tag followed by its value, enclosed in quotation marks: A tag pair section usually begins with the "Seven Tag Roster", which appears in the following order: ** Event: the name of the tournament or event. ** Site: the location of the event, in ", " format, where is the IOC country code for the country. Example: "New York City, NY USA" ** Date: the starting date of the game, in "YYYY.MM.DD" format. Unknown values are specified by "??". Examples: "2008.12.09" and "2009.01.??". ** Round: the round of the game. In some events where there are multiple round numbers, the numbers are delimited by a period. Examples: "2" and "4.2". ** White: the player playing White, in ", " format. ** Black: the player playing Black. ** Result: the result of the game. There are only four possible values: "1-0" (White won), "0-1" (Black won), "1/2-1/2" (Draw), and "*" (Undetermined, e.g. game abandoned, still in progress). Other common tags used are: * Time: Time the game started, in "HH:MM:SS" format, in local clock time. * Termination: Gives more details about the termination of the game. It may be "abandoned", "adjudication" (result determined by third-party adjudication), "death", "emergency", "normal", "rules infraction", "time forfeit", or "unterminated". * FEN: The initial position of the chess board, in Forsyth-Edwards Notation. Movetext The movetext section consists of a sequence of moves in Standard Algebraic Notation. A move starts with a number followed by either one dot (White to move) or three dots (Black to move) followed by the corresponding move or moves. Example: " . e4 e5 . Nc3" and " ... Ke3" Movetext SAN Piece letters: * King - K * Queen - Q * Bishop - B * Knight - N * Rook - R * Pawn - (omitted) Board square: The board square is specified as per the usual algebraic chess notation: the file letter followed by the rank number. A move is usually indicated by the piece letter of the piece that moved, followed by the landing square of the move. If a capture is made, an "x" is inserted before the board square. There is a special case for pawns: the file letter of the source square of the move must be inserted before the "x". En passant moves do not have special notation. In pawn promotions, an equal sign "=" followed by the promoted piece letter is appended. In case of disambiguities (that is, another piece can also move to that square and result with the same notation), if they can be distinguished by file letter, the letter is inserted after the piece letter, otherwise if they can be be distinguished by rank number, the number is inserted, otherwise, the full source square is inserted. Note that it's impossible for this to occur for pawns. Castling kingside is "O-O", castling queenside is "O-O-O" (letter Os are used). Checking moves are appended with a plus sign "+"; checkmating moves are appended with a number sign "#". Comments * Comments may be started using a semicolon ";" which continues to the end of the line, or enclosed within curly brackets "{}". Examples: * * . e4 * . e4 } ... e5 Example Here is an example from the Wikipedia article: . e4 e5 . Nf3 Nc6 . Bb5 } ... a6 . Ba4 Nf6 . O-O Be7 . Re1 b5 . Bb3 d6 . c3 O-O . h3 Nb8 . d4 Nbd7 . c4 c6 . cxb5 axb5 . Nc3 Bb7 . Bg5 b4 . Nb1 h6 . Bh4 c5 . dxe5 Nxe4 . Bxe7 Qxe7 . exd6 Qf6 . Nbd2 Nxd6 . Nc4 Nxc4 . Bxc4 Nb6 . Ne5 Rae8 . Bxf7+ Rxf7 . Nxf7 Rxe1+ . Qxe1 Kxf7 . Qe3 Qg5 . Qxg5 hxg5 . b3 Ke6 . a3 Kd6 . axb4 cxb4 . Ra5 Nd5 . f3 Bc8 . Kf2 Bf5 . Ra7 g6 . Ra6+ Kc5 . Ke1 Nf4 . g3 Nxh3 . Kd2 Kb5 . Rd6 Kc5 . Ra6 Nf2 . g4 Bd3 . Re6 Category:Board game file formats Category:Text file formats